﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Modules.TaskManager.Data;

namespace DotNetNuke.Modules.TaskManager.Components
{
    public class TaskControler
    {
        public static Task GetTask(int taskid)
        {
            return CBO.FillObject<Task> (DataProvider.Instance().GetTask(taskid));
        }

        public static IList<Task> GetTasks(int moduleid)
        {
            return CBO.FillCollection<Task>(DataProvider.Instance().GetTask(moduleid));
        }

        public static void DeleteTask(int taskid)
        {
            DataProvider.Instance().DeleteTask(taskid);
        }
        public static void DeleteTasks(int moduleid)
        {
            DataProvider.Instance().DeleteTasks(moduleid);
        }

        public static int SaveTask(Task t, int tabIid)
        {
            if (t.TaskId < 1)
            {
                DataProvider.Instance().AddTask(t);
            }
            else
            {
                DataProvider.Instance().UpdateTask(t);
            }
            return t.TaskId;

        }
    }
}